
//----------------------------------------
//	DEFINE BUILD TYPE
//----------------------------------------
#define _DIRECTX_BUILD
// #define _OPENGL_BUILD


//----------------------------------------
//	OTHER INCLUDES
//----------------------------------------
#include "AppLayer.h"
#include "ActorFactory.h"
#pragma comment( lib, "ActorFactory.lib" )
#include "TraceEngine.h"
#include "TEMacros.h"


//----------------------------------------
//	GLOBAL VARIABLES
//----------------------------------------

namespace TraceEngine
{
	// Constructor
	Engine::Engine( void )
		: m_pApp( nullptr )
	{

	}

	// Destructor
	Engine::~Engine( void )
	{
		
	}

	// Initialize the game engine
	bool Engine::init( void )
	{
		// Initialize the app layer
		m_pApp = new TraceEngine::AppLayer;
		if( !m_pApp )
			return false;
		m_pApp->initInstance();

		return true;
	}

	void Engine::shutdown( void )
	{
		TE_DELETE( this->m_pApp );
	}
}

// Entry Point
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR sCmdLine, int iCmdShow )
{
	UNREFERENCED_PARAMETER( hPrevInstance );

	// Memory leak checks
	int tmpDbgFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
	tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF;
	_CrtSetDbgFlag( tmpDbgFlag );

	// Initialize the engine
	TraceEngine::Engine* traceEngine = new TraceEngine::Engine();
	if( !traceEngine )
		return EXIT_FAILURE;
	traceEngine->init();

	// Destroy the engine
	traceEngine->shutdown();
	delete traceEngine;
	traceEngine = nullptr;

	return EXIT_SUCCESS;
}